package com.baitiaojun.user.api;

import com.baitiaojun.api.domain.user.User;
import com.baitiaojun.api.domain.user.UserCoin;
import com.baitiaojun.api.domain.user.UserInfo;
import com.baitiaojun.api.exception.ConditionException;
import com.baitiaojun.api.vo.JsonRes;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.util.List;
import java.util.Set;

/**
 * @类名 UserController
 * @描述 TODO
 * @作者 白条君
 * @创建日期 2022/11/20 13:24
 * @版本 1.0
 */
@RequestMapping("/user")
@Api("用户接口")
public interface UserApi {

    @ApiOperation("获取用户自己的所有信息")
    @GetMapping("/person-current-information")
    JsonRes getCurrentUserInfo() throws Exception;

    @ApiOperation("获取其他用户所有信息")
    @GetMapping("/person-other-information")
    JsonRes getOtherUserInfo(@ApiParam(value = "userinfoId(不是userid)", readOnly = true) @RequestParam Long id) throws Exception;

    @ApiOperation("绑定邮箱和密码修改")
    @PutMapping("/update-user")
    JsonRes updateUser(@ApiParam(value = "用户实体", required = true) @Valid @RequestBody User user, BindingResult result) throws Exception;

    @ApiOperation("更新用户基本信息")
    @PutMapping("/update-user-info")
    JsonRes updateUserInfo(@ApiParam(value = "用户信息实体", required = true) @Valid @RequestBody UserInfo userInfo, BindingResult result) throws Exception;

    @ApiOperation(value = "查看硬币数量", hidden = true)
    @GetMapping("/user-coin")
    JsonRes getUserCoin(@RequestParam Long userId);

    @ApiOperation(value = "更新硬币数量", hidden = true)
    @PutMapping("/edit-user-coin")
    JsonRes updateUserCoin(@RequestBody UserCoin userCoin, @RequestParam String token) throws ConditionException;

    @ApiOperation(value = "批量获取用户个人信息", hidden = true)
    @GetMapping("/user-infos")
    List<UserInfo> batchGetUserInfoByUserIdsSet(@RequestParam("userIds") Set<Long> userIds) throws Exception;

    @ApiOperation(value = "获取用户个人信息", hidden = true)
    @GetMapping("/user-info")
    UserInfo getUserInfo(@RequestParam("userId") Long userId) throws Exception;

    @ApiOperation("获取头像")
    @GetMapping("/user-avatar")
    void getUserAvatar(@ApiParam(value = "头像文件的url", required = true) @RequestParam String filePath) throws Exception;

    @ApiOperation(value = "上传头像", notes = "只能上传不超过20M的文件")
    @PostMapping("/new-user-avatar")
    JsonRes uploadUserAvatar(@ApiParam(value = "头像文件", required = true, name = "file") @RequestBody MultipartFile file) throws Exception;
}